package com.platform.server.controller;

import java.text.SimpleDateFormat;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.platform.server.service.FeedbackService;

@Controller
public class FeedbackController {
	
	@Autowired
	private FeedbackService feedbackService;
	
	/**
	 * 意见反馈列表
	 */
	@RequestMapping("/selectFeedbackList")
	public Object selectFeedbackList(HttpServletRequest request,String startTime,String endTime,String username,String mobile){
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		List<Map<String, Object>> lists = feedbackService.selectFeedbackList(startTime, endTime, username,mobile);
		for(int i = 0;i < lists.size();i++){
			lists.get(i).put("create_time",sdf.format(lists.get(i).get("create_time")));
		}
		request.setAttribute("lists",lists);
		request.setAttribute("nums",lists.size());
		return "/ui/feedback/feedback_list.jsp";
	}
	
	/**
	 * 删除意见反馈
	 */
	@RequestMapping("/deleteFeedback")
	public Object deleteFeedback(String id){
		int flag = feedbackService.deleteFeedback(id);
		return "/selectFeedbackList";
	}
}
